<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
 <head>
 <title>AJAX实际操作注册验证用户名</title>
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.5.1.min.js"></script>
 </head>
 <body>
 <form action="JSLoginServlet" method="post">
 <script type="text/javascript">
 $(function () {
   $("[name=username]").blur(function () {
    $.ajax({
     type:"get",
     url:"Findusername?name="+$("[name=username]").val(),
     success:function (data) {
      //alert(data);
      if (data!="1"){
    	  alert(data);
       $("#show").html("用户名可用")
      }else {
       $("#show").html("用户名不可用")
      }
     }
    })
   })
  });
 </script>

 账号<input type="text" name="username"><span id="show"></span></br>
 密码<input type="password" name="password"></br>
 <input type="submit" value="提交">
 </form>
 </body>
</html>